package com.team233.zuccecho.repository;

import com.team233.zuccecho.Bean.Feedback;
import com.team233.zuccecho.Bean.Questionnaire;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface QuestionnaireRepository extends JpaRepository<Questionnaire,Long> {
    @Query(value="select * from questionnaire where teacher_id=?1",nativeQuery = true)
    List<Questionnaire> findByTeaId(String tea_id);

    @Query(value="select * from questionnaire where questionnaire_id=?1",nativeQuery = true)
    Questionnaire findQNById(long questionnaire_id);

    //获取学生所有问卷
    @Query(value = "SELECT * FROM questionnaire\n" +
            "WHERE clazz_id IN\n" +
            "(SELECT clazz_id FROM stu_clazz WHERE student_id =?1) limit 10",nativeQuery = true)
    List<Questionnaire> getStuALlQn(long stu_id);

    //获取教师的所有问卷
    @Query(value = "SELECT * FROM questionnaire\n" +
            "WHERE teacher_id =?1 limit 10",nativeQuery = true)
    List<Questionnaire> getTeaALlQn(long tea_id);

}
